package cn.wen.yaling.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import cn.wen.yaling.commons.entity.TypeEntity;
import cn.wen.yaling.commons.vo.BlackListAddVO;
import cn.wen.yaling.commons.vo.BlackListUpdateVO;
import cn.wen.yaling.commons.vo.TypeAddVO;
import cn.wen.yaling.commons.vo.TypeUpdateVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.wen.yaling.commons.entity.BlackListEntity;
import cn.wen.yaling.xo.service.BlackListService;
import cn.wen.yaling.commons.utils.PageUtils;
import cn.wen.yaling.commons.utils.ResultEntity;



/**
 * 
 *
 * @author FY
 * @email 932043654@qq.com
 * @date 2022-08-13 02:07:36
 */
@RestController
public class BlackListController {

    @Autowired
    private BlackListService blackListService;

    /**
     * 获取当前全部的黑名单列表
     * @return
     */
    @GetMapping("/admin/black/list")
    public ResultEntity getAllBackList() {
        return blackListService.getBlackList();
    }

    /**
     * 查询IP列表
     * @return
     */
    @GetMapping("/admin/black/search/list")
    public ResultEntity searchType(@RequestParam("blackIp") String blackIp) {
        return blackListService.searchBlackList(blackIp);
    }

    /**
     * 添加分类
     * @return
     */
    @PostMapping("/admin/black/add")
    public ResultEntity addBlack(@RequestBody BlackListAddVO black) {
        return blackListService.addBlack(black);
    }

    /**
     * 删除分类
     * @return
     */
    @PostMapping("/admin/black/delete")
    public ResultEntity deleteBlack(@RequestParam("blackIds") List<Integer> blackIds) {
        return blackListService.deleteBlackByIds(blackIds);
    }

    /**
     * 删除分类
     * @return
     */
    @PostMapping("/admin/black/update")
    public ResultEntity updateBlack(@RequestBody BlackListUpdateVO black) {
        return blackListService.updateBlackById(black);
    }



}
